<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Popover - Adjustment</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
    />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
    <script type="module">
      import { popoverController } from '../../../../dist/ionic/index.esm.js';
      window.popoverController = popoverController;
    </script>
  </head>
  <body>
    <ion-app>
      <ion-content>
        <p style="text-align: center">Click everywhere to open the popover.</p>
      </ion-content>
    </ion-app>

    <script>
      document.querySelector('ion-content').addEventListener('click', handleButtonClick);

      async function handleButtonClick(ev) {
        const popover = await popoverController.create({
          component: 'popover-example-page',
          event: ev,
          reference: 'event',
        });

        popover.present();
      }

      customElements.define(
        'popover-example-page',
        class PopoverContent extends HTMLElement {
          connectedCallback() {
            this.innerHTML = `
              <ion-list>
                <ion-list-header>Ionic</ion-list-header>
                <ion-item button>Learn Ionic</ion-item>
                <ion-item button>Documentation</ion-item>
                <ion-item button>Showcase</ion-item>
                <ion-item button>GitHub Repo</ion-item>
                <ion-item button>Another Item</ion-item>
              </ion-list>
            `;
          }
        }
      );
    </script>
  </body>
</html>
